define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {

        /**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_getlist(result) {
			if(false) {
				result ='{"success":true,"msg":"","result":{"contact_name":"张三","contact_way":"18912345678","goods_id":"001","goods_name":"螺丝刀","goods_state":"transfer","transfer_type":"店铺转让","store_id":"001","store_name":"世达","store_info":[{"name":"描述相符","avg_point":8,"avg_percent":80},{"name":"服务态度","avg_point":8,"avg_percent":80}],"property":[{"id":"001","name":"品牌名","value":"博世"},{"id":"002","name":"转让类型","value":"转让所有权"},{"id":"003","name":"所属类别","value":"电动工具"},{"id":"004","name":"区域","value":"北京市"}],"bn":"P58983D5B7FD174002","brief":"一字螺丝刀","image":[{"id":"001","url":"001.jpg"},{"id":"002","url":"002.jpg"}],"price":"100.00","market_price":"90.00","product_bn":"G58983D5B7FCF13474"},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}

		//返回信息
		return {
            //获得经营转让的信息一览
			detail: function(goods_id,callback) {
				Http.post({
						method: 'info.transfer.detail',
                        goods_id:goods_id
					},
					function(result) {
						//请求成功
                        if(callback){
                            callback(get_data_getlist(result).result);
                        }
					},
					function(e) {
						//请求异常
					},
					function() {
						//请求完成，一般不做什么事情
					});
			},
			//收藏店铺
			addstore: function(store_id,callback) {
				Http.post({
					method: 'member.favorite.addstore',
                    store_id:store_id
				},
				function(result) {
					//请求成功
                    if(callback){
                        callback(result);
                    }
				},
				function(e) {
					//请求异常
				},
				function() {
					//请求完成，一般不做什么事情
				});
			},
			//收藏商品
			addgoods: function(goods_id,callback) {
				Http.post({
					method: 'member.favorite.addgoods',
                    goods_id:goods_id
				},
				function(result) {
					//请求成功
                    if(callback){
                        callback(result);
                    }
				},
				function(e) {
					//请求异常
				},
				function() {
					//请求完成，一般不做什么事情
				});
			}
			
			
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Transferdetail", factory);
});